import time
from time import sleep

from base.base import Base
import page


class PageWebOrder(Base):
    # 点击订单
    def page_web_click_order(self):
        sleep(2)
        self.base_click_el(page.web_order)

    # 点击发货单
    def page_web_click_deliver_order(self):
        self.base_click_el(page.web_deliver_order)

    # 切换到iframe框架
    def page_web_switch_frame(self):
        self.base_switch_frame(page.web_iframe)

    # 点击去发货
    def page_web_click_go_goods(self):
        self.base_click_el(page.web_go_goods)

    # 选择物流公司
    def page_web_click_company(self):
        self.base_click_el(page.web_company)

    # 输入配送单号
    def page_web_input_deliver_number(self, value=str(time.strftime("%Y%m%d%H%M%S"))):
        self.base_input_el(page.web_deliver_number, value)

    # 点击确认发货
    def page_web_click_ok_order(self):
        self.base_click_el(page.web_ok_order)

    # 点击打印配置单
    def page_web_click_print(self):
        self.base_click_el(page.web_print_order)

    # 获取订单编号
    def page_web_get_order_number(self):
        return self.base_get_text(page.web_get_order_number)

    # 发货业务
    def page_web_order(self):
        self.page_web_click_order()
        self.page_web_click_deliver_order()
        self.page_web_switch_frame()
        self.page_web_click_go_goods()
        self.page_web_click_company()
        self.page_web_input_deliver_number()
        self.page_web_click_ok_order()
        self.page_web_click_print()

